<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>私人订制</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		
		<script type="text/javascript" src="../js/jquery-1.11.0.js" ></script>
		<script type="text/javascript" src="../js/rem.js" ></script>
		<script type="text/javascript" src="../js/Base64.min.js" ></script>
		<script type="text/javascript" src="../js/aikxian-common.js" ></script>
		<script type="text/javascript" src="../js/common.js?id=0001" ></script>
		<script type="text/javascript" src="../js/showBo.js" ></script>
		<link rel="stylesheet" type="text/css" href="../css/showBo.css"/>
		<style>
			/*===========样式常规设置=========================================*/
			body,ul,li,dl,dt,dd,p,ol,h1,h2,h3,h4,h5,h6,form,img,table,fieldset,legend{margin:0; padding:0;}
			ul,li,ol{list-style:none;}
			img,fieldset{border:0; }
			/*img{display:block;}*/
			a{text-decoration:none;}
			h1,h2,h3,h4,h5,h6{font-weight:100;}
			body{font-family: "Microsoft Yahei","微软雅黑","Tahoma","Helvetica","STHeiti";}
			input,a,select{outline:none;}
			i{font-style:normal;}
			body{
				font-size: 0.3rem;	
				background:#efeff4;
				padding-bottom: 2rem;
				overflow: hidden;
			}
			header{
				width:80%;
				height:1.5rem;
				line-height: 1.5rem;
				border-bottom: 1px solid #ccc;
				text-align: center;
				font-weight: 600;
				margin:0 auto;
			}
			.main{
				padding:0.3rem 0.5rem;
				font-size:0.28rem;
				/*background: #fff;*/
			}
			label{
				display: block;
				width:100%;
				margin-top: 0.3rem;
			}
			select{
				width:4rem;
				height:0.7rem;
				margin-left:0.1rem;
				background: #fff;
				border:none;
				border-radius: 4px;
				-webkit-border-radius: 4px;
			}
			input{
				width:3.8rem;
				overflow:hidden;
				height:0.6rem;
				margin-left:0.1rem;
				border:none;
				border-radius: 4px;
				-webkit-border-radius: 4px;
			}
			span{
				display:inline-block;
				width:1.5rem;
				text-align: right;
				font-size:0.28rem;
			}
			textarea{
				width:4rem;
				height:2rem;
				border:none;
				margin-left:0.1rem;
				border-radius: 4px;
				-webkit-border-radius: 4px;
			}
			.textareaSp{
				
				position: relative;
				top:-1rem;
			}
			
			.bottomBtn{
				width:100%;
				height:1.2rem;
				background: #bebebe;
				position: fixed;
				bottom: 0;
				left:0;
			}
			.bottomBtn i{
				display: block;
				width:100%;
				height:100%;
				color:#fff;
				text-align: center;
				line-height: 1.2rem;
				font-size: 0.4rem;
			}
			.redBtn{
				background:#D14A3E;
			}
			
		</style>
	</head>
	<body>
		<header>高端财富管理，从此刻开始！</header>
		<div class='main'>
			<h4>填写基本情况</h4>
			<label><span>客户类型</span>
				<select>
				
				</select>
			</label>
			<label><span>期限</span>
				<input type="text" pattern="[0-9]*" class='important important1 term' onkeyup='change()'/>月
			</label>
			<label><span>金额</span>
				<input placeholder="3000万元及以上" type="text" pattern="[0-9]*" class='important important2 amount' onkeyup='change()'/>万元
			</label>
			<label>
				<span class='textareaSp'>备注</span>
				<textarea placeholder="请写明具体需求(200字以内)" cols="" rows="3" class='remark' id='report_cont'></textarea>
			</label>
			<div style='margin-top:1rem;color:#666;font-size: 0.3rem;padding:0 0.2rem;'>提交需求后由运营、营销、资管进行资产分配</div>
		</div>
		<div class='bottomBtn'><i>提交</i></div>
		
		<script>
		//===================对文本框的一些限制========================= 
		 $('#report_cont').on('input', function(e) { 
		 var val = $(this).val().length; 
		 if($(this).attr('inputstart') === 'no') { 
		 return false; 
		 } 
		 if($(this).val().length > 200) { 
		 if(e.keyCode !== 8) { 
		 this.value = this.value.substr(0, 200); 
		 $("#txt").html("内容输入请在200字以内"); 
		 } 
		 } else { 
		 $("#txt").html(val + '/200'); 
		 } 
		 }).on('compositionstart', function() { // 判断中文输入开始 
		 $(this).attr('inputstart', 'no'); 
		 }).on('compositionend', function() { // 判断中文输入结束，在此期间不触发 input 事件 
		 $(this).attr('inputstart', 'yes'); 
		 var val = $(this).val().length; 
		 $("#txt").html(val + '/200'); 
		 }); 
		
		//=========================================================
		
		
		var oneOff=false;
		function change(){
				oneOff=true;
				if($(".important1").val()==''){
					//alert($(".important1").val());
					oneOff=false;
				}
				if($(".important2").val()==''){
					//alert($(".important2").val());
					oneOff=false;
				}
				
			if(oneOff){
					$(".bottomBtn").addClass('redBtn');
					
				}else{
					$(".bottomBtn").removeClass('redBtn');
				}
		}
		
		
		$(function(){
			var userId=$.getUrlParam("userId");
		
			jQuery(function(){
								jQuery.ajax({
									url:Product_release,
									type:"post",
									dataType:"text",//opName
									data:{commonURL:Product_release,'opName':'get_customer_typeList',"osFlag":'3'},
									async:false,
									success:function(serverinfo){
										var Data=Base64.decode(serverinfo);
//										console.log(Data);
										Data=JSON.parse(Data);
//										console.log(Data);
										//alert(Data.retMsg);
										var retMsg=decodeURI(Data.retMsg);
										//alert(retMsg);
//										console.log(retMsg);
										for(var i=0;i<Data.itemList.length;i++){
											var html='<option id='+Data.itemList[i].primary+'>'+Data.itemList[i].value+'</option>'
											$("select").append(html);
										}
									},
									error:function(){
//										alert("2");
//										console.log(Data.retMsg);				
									}
								});
							});
							
			
			
			function validate(obj,name){
				
			       var reg = new RegExp("^[0-9]*$");
			       var obj = obj;
			    if(!reg.test(obj.value)){
			    	Showbo.Msg.alert(name+'只能输入数字!')
			       return false;
			    }else{	
				    	//Showbo.Msg.alert('请输入数字22!')
				    	/* if($(".important1").val()<=0){
				    		alert('期限请输入大于0的值');
				    		return false;
				    	} */
				    	if(parseInt($(".important2").val())<parseInt(3000)){
				    		Showbo.Msg.alert('金额必须大于等于3000万元!')
				    		return false;
				    	}
				    	return true;
			    }
			    
			  }	
			//可以执行提交事件
			
				$(".bottomBtn").on('click',function(){
					//alert(oneOff);
					if(oneOff){
						//alert("oneOff");
					if(validate($('.term')[0],'期限')&&validate($('.amount')[0],'金额'))
					{
					$("select").each(function(){
						var $this=$(this);
						var sValue=$this.val();
	//					alert(sValue);
						var $option=$this.find("option");
						$option.each(function(){
							var $opthis=$(this);
							if(sValue==$(this).val()){
								var opId=$opthis.attr("id");
								$this.attr("id",opId);
							}
						})
					});	
//					userId: 财富师编号
					//var userId='DT1301407';
					
//					term:期限
					var term=$('.term').val();
//					amount:金额
					var amount=$('.amount').val();
//					remark:备注
					var remark=$('.remark').val();
//					custProp：客户性质
					var custProp=$('select').attr('id');
					
					var str="{'userId':'"+userId+"','term':'"+term+"','amount':'"+amount+"','remark':'"+remark+"','custProp':'"+custProp+"'}";
					console.log(str);
					str = Base64.encode(str);
					jQuery(function(){
								jQuery.ajax({
									url:Product_release,
									type:"post",
									dataType:"text",//opName
									data:{commonURL:Product_release,'param':str,'opName':'save_tailor_info',"osFlag":'3','versionNo':'a123'},
									async:false,
									success:function(serverinfo){
										var Data=Base64.decode(serverinfo);
										
										Data=JSON.parse(Data);
										//console.log(Data);
										//var retMsg=decodeURI(Data.retMsg);
										//console.log(retMsg);
										if(Data.retCode=='0'){
											var param='订制成功';
											closeWindow(param);
										}
									},
									error:function(){
										//alert('no');			
									}
								});
							});
					   }else{
						   //alert('请输入数字');
					   }
					};
				});
			
			
			
	 function closeWindow(param) {
	   param = param || "";
	   if (navigator.userAgent.toLowerCase().match(/android/i) == "android") {
	    window.AndroidFunction.closeWindow(String(param));
	   }
	   else{
	    window.webkit.messageHandlers.AppModel.postMessage({body: 'objc:///close:'+param});
	   }
	  }	
			//结束
			})
		</script>
	</body>
</html>
